package com.machinecontroller.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.machinecontroller.service.GuardService;
import com.machinecontroller.utils.ServiceUitl;

/**
 * 后台服务监控接收器
 * Created by zhangxuehui on 2017/12/20.
 */
public class ServiceMonitorBroadCasrReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
            //检查Service状态
            if (!ServiceUitl.isProcessRunning(context, "com.machinecontroller.service.GuardService")) {
                Intent i = new Intent(context, GuardService.class);
                context.startService(i);
            }
        }
    }
}
